package com.sxy.web; /**
 * @author 宋鑫宇
 * @version 1.0
 */

import com.sxy.pojo.Brand;
import com.sxy.service.BrandService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/selectByIdServlet")
public class SelectByIdServlet extends HttpServlet {
    private BrandService brandService = new BrandService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收数据
        String id = request.getParameter("id");
        //调用service层方法
        Brand brand = brandService.selectById(Integer.parseInt(id));
        //存储到request域中
        request.setAttribute("brand",brand);
        //请求转发到update.jsp
        request.getRequestDispatcher("/update.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
